<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:60:"/private/var/html/www/cltphp/app/admin/view/system/menu.html";i:1512803270;s:60:"/private/var/html/www/cltphp/app/admin/view/common/head.html";i:1505459052;s:60:"/private/var/html/www/cltphp/app/admin/view/common/foot.html";i:1503623996;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__STATIC__/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__ADMIN__/css/global.css" media="all">
    <link rel="stylesheet" href="__STATIC__/common/css/font.css" media="all">
</head>
<body class="skin-0">
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend><?php echo $title; ?></legend>
    </fieldset>
    <blockquote class="layui-elem-quote">
        <a href="<?php echo url('add'); ?>" class="layui-btn layui-btn-small"><?php echo lang('add'); ?>目录</a>
    </blockquote>

    <table class="layui-hide" id="menu" >
        {{#  layui.each(d.menus, function(index, menu){ }}
            <tr>
              <td>{{ menu.id }}</td>
              <td>{{ menu.pid }}：</td>
              <td>{{ menu.title }}</td>
              <td>{{ menu.sort }}</td>
              <td>{{ menu.status }}</td>
            </li>
        {{#  }); }}
    </table>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
</div>
<script type="text/javascript" src="__STATIC__/plugins/layui/layui.js"></script>


<script src="__STATIC__/common/js/jquery.2.1.1.min.js"></script>
<script>
    var menus = <?php echo $menus; ?>;
    layui.use('table', function(){
        var table = layui.table,$= layui.jquery;
        table.init('list', {});

        //执行一个 table 实例
        // var tableIn = table.render({
        //     elem: '#menu'
        //     ,page: true //开启分页
        //     ,cols: [[ //表头
        //         {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'},
        //         {field: 'pid', title: 'PID', width:80, sort: true, fixed: 'left'},
        //         {field: 'title', title: '用户名', width:250},
        //         {field: 'menustatus', align: 'center',title: '<?php echo lang("status"); ?>', width: 80,toolbar: '#status'},
        //     ]],
        //     data:menus
        // });

        // $('body').on('blur','.list_order',function() {
        //     var id = $(this).attr('data-id');
        //     var listorder = $(this).val();
        //     var loading = layer.load(1, {shade: [0.1, '#fff']});
        //     $.post('<?php echo url("cOrder"); ?>',{id:id,listorder:listorder},function(res){
        //         layer.close(loading);
        //         if(res.code === 1){
        //             layer.msg(res.msg, {time: 1000, icon: 1}, function () {
        //                 location.href = res.url;
        //             });
        //         }else{
        //             layer.msg(res.msg,{time:1000,icon:2});
        //         }
        //     })
        // });

        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'status') {
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post('<?php echo url("moduleState"); ?>', {'id': data.id}, function (res) {
                    layer.close(loading);
                    if (res.status == 1) {
                        if (res.moduleState == 1) {
                            obj.update({
                                status: '<a class="layui-btn layui-btn-warm layui-btn-mini" lay-event="status">开启</a>'
                            });
                        } else {
                            obj.update({
                                status: '<a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="status">禁用</a>'
                            });
                        }
                    } else {
                        layer.msg('操作失败！', {time: 1000, icon: 2});
                        return false;
                    }
                })
            }else if(obj.event === 'del'){
                layer.confirm('你确定要删除该模型吗？', {icon: 3}, function (index) {
                    $.post("<?php echo url('del'); ?>",{id:data.id},function(res){
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
    });




    function del(id) {
        layer.confirm('你确定要删除该栏目及其子栏目吗？', {icon: 3}, function (index) {
            $.post('<?php echo url("del"); ?>', {id: id}, function (data) {
                if (data.status === 1) {
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg(data.info,{icon:5});
                }
            });
            layer.close(index);
        });
    }
</script>